import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false

//挂载公共方法
import base from './methods'
Vue.use(base) //将全局函数当做插件来进行注册

// 引入element
import ElementUI, { CheckboxGroup, Message } from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)

// 引入iconfont
import iconfont from './assets/iconfont/iconfont.css'

// 引入js-md5
import md5 from 'js-md5'
Vue.prototype.md5 = md5

// 引入axios
import axios from 'axios'
Vue.prototype.axios = axios
axios.defaults.baseURL = '/insect'
// 添加响应拦截器
axios.interceptors.response.use(
  function(response) {
    if (response.data.code == 2) {
      router.push('/login')
    }
    return response
  },
  function(error) {
    return Promise.reject(error)
  }
)

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
